package demo.Socket.Grass_num_game;

import java.io.*;
import java.net.Socket;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/21-08-21-16:29
 * @Description：demo.Socket.Grass_num_game
 */
public class Grass_Tclient {
    public static void main(String[] args) {
        Socket socket = null;
        try {
            socket = new Socket(PropertiesUtils.properties.getProperty("address"),Integer.parseInt(PropertiesUtils.properties.getProperty("port")) );
            //socket = new Socket("127.0.0.1",6677);
            BufferedReader reader1 = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            System.out.println(reader1.readLine());
            BufferedReader reader2 = new BufferedReader(new InputStreamReader(System.in));
            String s = null;
            while (true){
                s = reader2.readLine();
                System.out.println(s);
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
                writer.write(s + "\r\n");
                writer.flush();
                s = reader1.readLine();
                System.out.println(s);
                if(s.startsWith("恭喜") || s.startsWith("很遗憾")){
                    break;
                }
            }
            reader1.close();
            reader2.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
